package com.warehouseprovider.service;

import com.warehouseprovider.dao.ZRouteMapper;
import entity.ResponseMessage;
import entity.Route;
import entity.StatusCode;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import service.ZRouteService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ZRouteServiceImpl implements ZRouteService {
    private Logger logger=Logger.getLogger(this.getClass());

    @Resource
    private ZRouteMapper zRouteMapper;

    /**
     * 查询路线
     * @return
     */
    @Override
    public ResponseMessage getRouteToStronger() {
        logger.info("ZRouteServiceImpl getRouteToStronger is start..... ");
        ResponseMessage msg=new ResponseMessage();
        List<Route> list=new ArrayList<>();
        list=zRouteMapper.getRouteToStronger();
        try {
            if(list==null){
                logger.error("ZRouteServiceImpl getRouteToStronger is error,param:"+list);
                msg.setCode(StatusCode.ERROR);
                msg.setFlag(false);
                msg.setMessage("查询路线失败！");
                return msg;
            }
        } catch (Exception e) {
            logger.error("ZRouteServiceImpl getRouteToStronger is error",e);
            e.printStackTrace();
            msg.setFlag(false);
            msg.setCode(StatusCode.ERROR);
            msg.setMessage("查询路线失败！进入catch...");
            return msg;
        }
        logger.debug("ZRouteServiceImpl getRouteToStronger is success,result:"+list);
        msg.setCode(StatusCode.ERROR);
        msg.setMessage("查询路线成功！");
        msg.setFlag(true);
        msg.setData(list);
        return msg;
    }
}
